#!/bin/bash

if [ -f ./log/pid.txt ]; then
    PID=$(cat ./log/pid.txt)
    if ps -p $PID > /dev/null; then
        echo "正在停止反馈服务，进程ID: $PID"
        kill $PID
        # 等待进程结束
        for i in {1..5}; do
            if ! ps -p $PID > /dev/null; then
                echo "反馈服务已停止"
                break
            fi
            sleep 1
        done
        # 如果进程还在运行，强制结束
        if ps -p $PID > /dev/null; then
            echo "服务未响应，强制结束进程"
            kill -9 $PID
        fi
    else
        echo "反馈服务未运行"
    fi
    rm ./log/pid.txt
else
    echo "未找到进程ID文件"
fi 